package com.example.demo.mapper;

import com.example.demo.pojo.User;
import com.example.demo.pojo.request.BaseRequest;
import com.example.demo.pojo.request.UserPageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //查询全部
    List<User> list();

    //分页
    List<User> page(UserPageRequest request);

    //添加
    @Insert("insert into library.user (name, username, age, sex, phone, address,id_card) values" +
            " (#{name}, #{username}, #{age}, #{sex}, #{phone}, #{address},#{idCard})")
    void save(User user);

    //查找
    @Select("select * from library.user where id=#{id}")
    User getUser(Integer id);

    //更新
    @Update("update library.user set name=#{name},username=#{username},age=#{age},sex=#{sex},phone=#{phone} " +
            ",address=#{address},update_time=#{updateTime} where id=#{id}")
    void getUserByID(User user);

    //删除
    @Delete("delete from library.user where id=#{id}")
    void delete(Integer id);
}
